/**
*
*构建
*/

var mongoose  = require('mongoose');
var BaseModel = require("./base_model");
var Schema    = mongoose.Schema;

var BuildSchema = new Schema({

    config:{
      type: Schema.Types.ObjectId,
      ref:'BuildConfig'
    },

    project:{ //冗余信息，为了快速查找
      type:Schema.Types.ObjectId, ref:'Project'
    },

    description:{
      type: String
    },

    creator:{
      type:String
    },

    state:{
      type:String,
      default: 'created' //created|readying|building|error|completing|completed|canceled|canceling   (just for local state, not  state in builder)
    },
    state_info: {
      type: String
    },
    //详细的结果信息,可能包括日志文件地址之类的信息
    result_detail: {
      type: Schema.Types.Mixed
    },

    //构建结果
    result: String,//success|failed

    token: {
      type:String
    },

    create_at: { type: Date, default: Date.now },
    update_at: { type: Date, default: Date.now }
});
BuildSchema.plugin(BaseModel);
module.exports = mongoose.model('Build', BuildSchema);
